set(MODULE protocol)

option(USE_LUA_PROTOCOL "use lua protocol" OFF)
option(USE_XCOM_PROTOCOL "use xcom protocol" ON)

aux_source_directory(.  DIRSRCS)
if (USE_LUA_PROTOCOL)
    aux_source_directory(lua  DIRSRCS)
endif(USE_LUA_PROTOCOL)

if (USE_XCOM_PROTOCOL)
    add_subdirectory(libxcom)
endif(USE_XCOM_PROTOCOL)

add_library(${MODULE} ${DIRSRCS})
target_include_directories(${MODULE} PUBLIC
    ${CMAKE_CURRENT_BINARY_DIR}/dbms
    ${PRODUCT_ROOT_DIR}
    )

if (USE_LUA_PROTOCOL)
    target_include_directories(${MODULE} PUBLIC
        ${LUA_INCLUDE_DIR}
        ${LUACPPINTERFACE_INCLUDE_DIR}
        ${LUACPPINTERFACE_INCLUDE_DIR}/../lua)
    target_link_directories(${MODULE} PUBLIC ${LUACPPINTERFACE_LIBS_DIR} ${LUA_LIBS_DIR})
    target_link_libraries(${MODULE} dbms  utils luacppinterface lua)
endif(USE_LUA_PROTOCOL)

if (USE_XCOM_PROTOCOL)
    target_include_directories(${MODULE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libxcom/include)
    target_link_libraries(${MODULE} dbms  utils xcom)
endif(USE_XCOM_PROTOCOL)

if (PROJECT_ENABLE_TEST)
  add_subdirectory(test)
endif()